﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Elysium.Demo;
using SIIE_ERP.Codigo;
using Microsoft.Win32;

namespace Elysium.Demo.Configuracion
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class CargaDatos_Main : UserControl
    {
        private UsuarioActivo _sesion;

        public CargaDatos_Main(ref UsuarioActivo usuario)
        {
            InitializeComponent();
            this._sesion = usuario;

            if (!IsOfficeInstalled())
            {
                ButtonArticulos.IsEnabled = false;
                ButtonClientes.IsEnabled = false;
                ButtonProveedores.IsEnabled = false;

                MessageBox.Show("Necesita tener Microsoft Excel instalado en su computadora para poder usar este módulo.");
            }
        }

        private bool IsOfficeInstalled()
        {
            RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe");
            if (key != null)
            {
                key.Close();
            }
            return key != null;
        }


        private void ButtonProveedores_Click(object sender, RoutedEventArgs e)
        {
            ((ScrollViewer)this.Parent).Content = new CargaDatos_Proveedor1(ref _sesion);
        }

        private void ButtonClientes_Click(object sender, RoutedEventArgs e)
        {
            ((ScrollViewer)this.Parent).Content = new CargaDatos_Cliente1(ref _sesion);
        }

        private void ButtonArticulos_Click(object sender, RoutedEventArgs e)
        {
            ((ScrollViewer)this.Parent).Content = new CargaDatos_Articulo1(ref _sesion);
        }

        private void ButtonInformacion_Click_1(object sender, RoutedEventArgs e)
        {
            WindowAyuda Ayuda = new Elysium.Demo.WindowAyuda("CargaDatos.htm", "Ayuda");
            Ayuda.Owner = SIIE_ERP.View.NavegacionUI.GetParentWindow(this); Ayuda.ShowDialog();
        }
    }
}
